package com.hpu.dao;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

import com.hpu.entity.User_Comment;
import com.hpu.util.DBhelp;
import com.hpu.util.RowMapper;

public class UserCommentDao {

	private DBhelp<User_Comment> comBhelp = new DBhelp<User_Comment>();
	public List<User_Comment> findAll(){
		String sql = "select id,comment,create_time,user_id,order_id from user_comment";
		return comBhelp.executeQueryForList(sql, new UserCommentRowMapper());
	}
	public void delcomment(String commentid){
		String sql = "delete from user_comment where id = ?";
		comBhelp.executeSQL(sql, commentid);
	}
	private class UserCommentRowMapper implements RowMapper<User_Comment>{
		public User_Comment mapperRow(ResultSet rs) throws SQLException {
			User_Comment comment = new User_Comment();
			comment.setId(rs.getInt("id"));
			comment.setComment(rs.getString("comment"));
			comment.setCreate_time(rs.getString("create_time"));
			comment.setUser_id(rs.getString("user_id"));
			comment.setOrder_id(rs.getInt("order_id"));
			return comment;
		}
		
		
	}
}
